});
Signals.addSignalMethods(DBusEventSource.prototype);
-// Calendar:
-// @eventSource: is an object implementing the EventSource API, e.g. the
-// requestRange(), getEvents(), hasEvents() methods and the ::changed signal.
const Calendar = new Lang.Class({
Name: 'Calendar',
- _init: function(eventSource) {
- if (eventSource) {
- this._eventSource = eventSource;
-
- this._eventSource.connect('changed', Lang.bind(this,
- function() {
- this._update(false);
- }));
- }
-
+ _init: function() {
this._weekStart = Shell.util_get_week_start();
this._weekdate = NaN;
this._digitWidth = NaN;
this._buildHeader ();
},
+ // @eventSource: is an object implementing the EventSource API, e.g. the
+ // requestRange(), getEvents(), hasEvents() methods and the ::changed signal.
+ setEventSource: function(eventSource) {
+ if (this._eventSource) {
+ this._eventSource.disconnect(this._eventSourceChangedId);
+ this._eventSource = null;
+ }
+
+ this._eventSource = eventSource;
+
+ if (this._eventSource) {
+ this._eventSourceChangedId = this._eventSource.connect('changed', Lang.bind(this, function() {
+ this._update(false);
+ }));
+ this._update(true);
+ }
+ },
+
// Sets the calendar to show a specific date
setDate: function(date, forceReload) {
if (!_sameDay(date, this._selectedDate)) {
const EventsList = new Lang.Class({
Name: 'EventsList',
- _init: function(eventSource) {
+ _init: function() {
this.actor = new St.BoxLayout({ vertical: true, style_class: 'events-header-vbox'});
this._date = new Date();
- this._eventSource = eventSource;
- this._eventSource.connect('changed', Lang.bind(this, this._update));
this._desktopSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
this._desktopSettings.connect('changed', Lang.bind(this, this._update));
this._weekStart = Shell.util_get_week_start();
+ },
- this._update();
+ setEventSource: function(eventSource) {
+ if (this._eventSource) {
+ this._eventSource.disconnect(this._eventSourceChangedId);
+ this._eventSource = null;
+ }
+
+ this._eventSource = eventSource;
+
+ if (this._eventSource) {
+ this._eventSourceChangedId = this._eventSource.connect('changed', Lang.bind(this, this._update));
+ }
},
_addEvent: function(dayNameBox, timeBox, eventTitleBox, includeDayName, day, time, desc) {
this._date.style_class = 'datemenu-date-label';
vbox.add(this._date);
- if (Main.sessionMode.showCalendarEvents) {
- this._eventSource = new Calendar.DBusEventSource();
- this._eventList = new Calendar.EventsList(this._eventSource);
- } else {
- this._eventSource = null;
- this._eventList = null;
- }
-
- // Calendar
- this._calendar = new Calendar.Calendar(this._eventSource);
+ this._eventList = new Calendar.EventsList();
+ this._calendar = new Calendar.Calendar();
this._calendar.connect('selected-date-changed',
Lang.bind(this, function(calendar, date) {
item.actor.reparent(vbox);
}
- if (Main.sessionMode.showCalendarEvents) {
- // Add vertical separator
-
- item = new St.DrawingArea({ style_class: 'calendar-vertical-separator',
- pseudo_class: 'highlighted' });
- item.connect('repaint', Lang.bind(this, _onVertSepRepaint));
- hbox.add(item);
+ this._separator = new St.DrawingArea({ style_class: 'calendar-vertical-separator',
+ pseudo_class: 'highlighted' });
+ this._separator.connect('repaint', Lang.bind(this, _onVertSepRepaint));
+ hbox.add(this._separator);
- // Fill up the second column
- vbox = new St.BoxLayout({name: 'calendarEventsArea',
- vertical: true});
- hbox.add(vbox, { expand: true });
+ // Fill up the second column
+ vbox = new St.BoxLayout({ name: 'calendarEventsArea',
+ vertical: true });
+ hbox.add(vbox, { expand: true });
- // Event list
- vbox.add(this._eventList.actor, { expand: true });
+ // Event list
+ vbox.add(this._eventList.actor, { expand: true });
- item = new PopupMenu.PopupMenuItem(_("Open Calendar"));
- item.connect('activate', Lang.bind(this, this._onOpenCalendarActivate));
- item.actor.can_focus = false;
- vbox.add(item.actor, {y_align: St.Align.END, expand: true, y_fill: false});
- }
+ this._openCalendarItem = new PopupMenu.PopupMenuItem(_("Open Calendar"));
+ this._openCalendarItem.connect('activate', Lang.bind(this, this._onOpenCalendarActivate));
+ this._openCalendarItem.actor.can_focus = false;
+ vbox.add(this._openCalendarItem.actor, {y_align: St.Align.END, expand: true, y_fill: false});
// Whenever the menu is opened, select today
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
this._clock = new GnomeDesktop.WallClock();
this._clock.connect('notify::clock', Lang.bind(this, this._updateClockAndDate));
this._updateClockAndDate();
+
+ Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
+ this._sessionUpdated();
+ },
+
+ _setEventsVisibility: function(visible) {
+ this._separator.visible = visible;
+ this._eventList.visible = visible;
+ this._openCalendarItem.visible = visible;
+ },
+
+ _setEventSource: function(eventSource) {
+ this._calendar.setEventSource(eventSource);
+ this._eventList.setEventSource(eventSource);
+ },
+
+ _sessionUpdated: function() {
+ let eventSource;
+ let showEvents = Main.sessionMode.showCalendarEvents;
+ if (showEvents) {
+ eventSource = new Calendar.DBusEventSource();
+ } else {
+ eventSource = null;
+ }
+ this._setEventSource(eventSource);
+ this._setEventsVisibility(showEvents);
},
_updateClockAndDate: function() {
const St = imports.gi.St;
const ExtensionUtils = imports.misc.extensionUtils;
+const Main = imports.ui.main;
const ExtensionState = {
ENABLED: 1,
const ENABLED_EXTENSIONS_KEY = 'enabled-extensions';
+var initted = false;
+var enabled;
+
function disableExtension(uuid) {
let extension = ExtensionUtils.extensions[uuid];
if (!extension)
function onEnabledExtensionsChanged() {
let newEnabledExtensions = global.settings.get_strv(ENABLED_EXTENSIONS_KEY);
+ if (!enabled)
+ return;
+
// Find and enable all the newly enabled extensions: UUIDs found in the
// new setting, but not in the old one.
newEnabledExtensions.filter(function(uuid) {
enabledExtensions = newEnabledExtensions;
}
-function loadExtensions() {
+function _loadExtensions() {
global.settings.connect('changed::' + ENABLED_EXTENSIONS_KEY, onEnabledExtensionsChanged);
enabledExtensions = global.settings.get_strv(ENABLED_EXTENSIONS_KEY);
});
finder.scanExtensions();
}
+
+function enableAllExtensions() {
+ if (enabled)
+ return;
+
+ if (!initted) {
+ _loadExtensions();
+ initted = true;
+ } else {
+ enabledExtensions.forEach(function(uuid) {
+ enableExtension(uuid);
+ });
+ }
+ enabled = true;
+}
+
+function disableAllExtensions() {
+ if (!enabled)
+ return;
+
+ if (initted) {
+ enabledExtensions.forEach(function(uuid) {
+ disableExtension(uuid);
+ });
+ }
+
+ enabled = false;
+}
+
+function _sessionUpdated() {
+ if (Main.sessionMode.allowExtensions)
+ enableAllExtensions();
+ else
+ disableAllExtensions();
+}
+
+function init() {
+ Main.sessionMode.connect('updated', _sessionUpdated);
+ _sessionUpdated();
+}
this._monitors = [];
this._inOverview = false;
- this._isLocked = false;
this._updateRegionIdle = 0;
this._freezeUpdateCount = 0;
},
init: function() {
- Main.overview.connect('showing',
- Lang.bind(this, this._overviewShowing));
- Main.overview.connect('hidden',
- Lang.bind(this, this._overviewHidden));
- Main.screenShield.connect('lock-status-changed',
- Lang.bind(this, this._lockStatusChanged));
+ Main.overview.connect('showing', Lang.bind(this, this._overviewShowing));
+ Main.overview.connect('hidden', Lang.bind(this, this._overviewHidden));
+ Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
},
addActor: function(actor, params) {
if (!actorData.isToplevel)
continue;
- if (this._inOverview || this._isLocked)
+ if (this._inOverview || Main.sessionMode.hasWindows)
visible = true;
else if (this.findMonitorForActor(actorData.actor).inFullscreen)
visible = false;
this._queueUpdateRegions();
},
- _lockStatusChanged: function(shield, locked) {
- this._isLocked = locked;
+ _sessionUpdated: function() {
this._updateVisibility();
this._queueUpdateRegions();
},
});
}
+function _sessionUpdated() {
+ Meta.keybindings_set_custom_handler('panel-run-dialog', sessionMode.hasRunDialog ? openRunDialog : null);
+ loadTheme();
+}
+
function start() {
// These are here so we don't break compatibility.
global.logError = window.log;
sessionMode.createSession();
- panel.init();
layoutManager.init();
keyboard.init();
overview.init();
- if (sessionMode.hasWorkspaces)
- global.screen.override_workspace_layout(Meta.ScreenCorner.TOPLEFT,
- false, -1, 1);
-
- if (sessionMode.hasRunDialog) {
- Meta.keybindings_set_custom_handler('panel-run-dialog', function() {
- getRunDialog().open();
- });
- }
-
- if (sessionMode.hasOverview) {
- Meta.keybindings_set_custom_handler('panel-main-menu', function () {
- overview.toggle();
- });
+ global.screen.override_workspace_layout(Meta.ScreenCorner.TOPLEFT,
+ false, -1, 1);
+ Meta.keybindings_set_custom_handler('panel-main-menu', Lang.bind(overview, overview.toggle));
+ global.display.connect('overlay-key', Lang.bind(overview, overview.toggle));
- global.display.connect('overlay-key',
- Lang.bind(overview, overview.toggle));
- }
+ sessionMode.connect('update', _sessionUpdated);
+ _sessionUpdated();
// Provide the bus object for gnome-session to
// initiate logouts.
_nWorkspacesChanged();
- if (sessionMode.allowExtensions) {
- ExtensionDownloader.init();
- ExtensionSystem.loadExtensions();
- }
+ ExtensionDownloader.init();
+ ExtensionSystem.init();
}
let _workspaces = [];
if (!sessionMode.hasRunDialog)
return false;
- getRunDialog().open();
+ openRunDialog();
return true;
case Meta.KeyBindingAction.PANEL_MAIN_MENU:
case Meta.KeyBindingAction.OVERLAY_KEY:
return lookingGlass;
}
-function getRunDialog() {
+function openRunDialog() {
if (runDialog == null) {
runDialog = new RunDialog.RunDialog();
}
- return runDialog;
+ runDialog.open();
}
/**
const Overview = new Lang.Class({
Name: 'Overview',
- _init : function() {
- this.isDummy = !Main.sessionMode.hasOverview;
+ _init: function() {
+ this._overviewCreated = false;
+
+ Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
+ this._sessionUpdated();
+ },
- // We only have an overview in user sessions, so
- // create a dummy overview in other cases
- if (this.isDummy) {
- this.animationInProgress = false;
- this.visible = false;
+ _createOverview: function() {
+ if (this._overviewCreated)
return;
- }
+
+ if (this.isDummy)
+ return;
+
+ this._overviewCreated = true;
// The main BackgroundActor is inside global.window_group which is
// hidden when displaying the overview, so we create a new
this._needsFakePointerEvent = false;
},
+ _sessionUpdated: function() {
+ this.isDummy = !Main.sessionMode.hasOverview;
+ this._createOverview();
+ },
+
// The members we construct that are implemented in JS might
// want to access the overview as Main.overview to connect
// signal handlers and so forth. So we create them after
this._sync();
},
- setLockedState: function(locked) {
- if (locked) {
- this.hide();
- } else {
- this.show();
- this._sync();
- }
- },
-
_sync: function() {
let tracker = Shell.WindowTracker.get_default();
let focusedApp = tracker.focus_app;
this.actor.remove_style_class_name('in-overview');
}));
- Main.screenShield.connect('lock-status-changed', Lang.bind(this, this._onLockStateChanged));
-
this.menuManager = new PopupMenu.PopupMenuManager(this);
this._leftBox = new St.BoxLayout({ name: 'panelLeft' });
Main.layoutManager.panelBox.add(this.actor);
Main.ctrlAltTabManager.addGroup(this.actor, _("Top Bar"), 'start-here-symbolic',
{ sortGroup: CtrlAltTab.SortGroup.TOP });
+
+ Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
+ this._updatePanel();
},
_getPreferredWidth: function(actor, forHeight, alloc) {
menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
},
- init: function() {
+ set boxOpacity(value) {
+ let isReactive = value > 0;
+
+ this._leftBox.opacity = value;
+ this._leftBox.reactive = isReactive;
+ this._centerBox.opacity = value;
+ this._centerBox.reactive = isReactive;
+ this._rightBox.opacity = value;
+ this._rightBox.reactive = isReactive;
+ },
+
+ get boxOpacity() {
+ return this._leftBox.opacity;
+ },
+
+ _updatePanel: function() {
let panel = Main.sessionMode.panel;
- this._initBox(panel.left, this._leftBox);
- this._initBox(panel.center, this._centerBox);
- this._initBox(panel.right, this._rightBox);
+ this._hideIndicators();
+ this._updateBox(panel.left, this._leftBox);
+ this._updateBox(panel.center, this._centerBox);
+ this._updateBox(panel.right, this._rightBox);
},
_initBox: function(elements, box) {
// bluetooth or network)
continue;
}
+ }
+ },
+
+ _tweenAndUpdatePanel: function() {
+ this._closeIndicatorMenus();
+
+ Tweener.addTween(this, {
+ boxOpacity: 0,
+ time: Overview.ANIMATION_TIME / 2,
+ transition: 'easeOutQuad',
+ onCompleteScope: this,
+ onComplete: function() {
+ this._updatePanel();
+ Tweener.addTween(this, {
+ boxOpacity: 255,
+ time: Overview.ANIMATION_TIME / 2,
+ transition: 'easeOutQuad'
+ });
+ }
+ });
+ },
+
+ _sessionUpdated: function() {
+ this._tweenAndUpdatePanel();
+ },
+
+ _closeIndicatorMenus: function() {
+ for (let role in this.statusArea) {
+ let indicator = this.statusArea[role];
+ indicator.menu.close();
+ }
+ },
+
+ _hideIndicators: function() {
+ for (let role in PANEL_ITEM_IMPLEMENTATIONS) {
+ let indicator = this.statusArea[role];
+ if (!indicator)
+ continue;
+ indicator._panelContainer.hide();
+ }
+ },
+
+ _ensureIndicator: function(role) {
+ let indicator = this.statusArea[role];
+ if (!indicator) {
+ let constructor = PANEL_ITEM_IMPLEMENTATIONS[role];
+ if (!constructor) {
+ // This icon is not implemented (this is a bug)
+ return null;
+ }
+ indicator = new constructor(this);
+ this.statusArea[role] = indicator;
+ }
+ return indicator;
+ },
+
+ _updateBox: function(elements, box) {
+ let nChildren = box.get_n_children();
+
+ for (let i = 0; i < elements.length; i++) {
+ let role = elements[i];
+ let indicator = this._ensureIndicator(role);
+ if (indicator == null)
+ continue;
- let indicator = new constructor(this);
- this._addToPanelBox(role, indicator, i, box);
+ this._addToPanelBox(role, indicator, i + nChildren, box);
}
},
_addToPanelBox: function(role, indicator, position, box) {
- box.insert_child_at_index(indicator.actor, position);
+ let container = indicator._panelContainer;
+ if (!container) {
+ container = new St.Bin({ y_fill: true,
+ child: indicator.actor });
+ indicator._panelContainer = container;
+ }
+ container.show();
+
+ let parent = container.get_parent();
+ if (parent) {
+ parent.remove_actor(container);
+ }
+
+ box.insert_child_at_index(container, position);
if (indicator.menu)
this.menuManager.addMenu(indicator.menu);
this.statusArea[role] = indicator;
let destroyId = indicator.connect('destroy', Lang.bind(this, function(emitter) {
delete this.statusArea[role];
emitter.disconnect(destroyId);
+ container.destroy();
}));
},
right: this._rightBox
};
let boxContainer = boxes[box] || this._rightBox;
+ this.statusArea[role] = indicator;
this._addToPanelBox(role, indicator, position, boxContainer);
return indicator;
- },
-
- _onLockStateChanged: function(shield, locked) {
- for (let id in this.statusArea)
- this.statusArea[id].setLockedState(locked);
- },
+ }
});
}
},
- setLockedState: function(locked) {
- // default behaviour is to hide completely
- if (locked)
- this.menu.close();
- this.actor.visible = !locked;
- },
-
_onButtonPress: function(actor, event) {
if (!this.menu)
return;
this._activeMenuItem = null;
this._childMenus = [];
this._settingsActions = { };
+
+ this._sessionUpdatedId = Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
+ },
+
+ _sessionUpdated: function() {
+ this._setSettingsVisibility(Main.sessionMode.allowSettings);
},
addAction: function(title, callback) {
},
addSettingsAction: function(title, desktopFile) {
- if (!Main.sessionMode.allowSettings)
- return null;
-
let menuItem = this.addAction(title, function() {
let app = Shell.AppSystem.get_default().lookup_setting(desktopFile);
return menuItem;
},
- setSettingsVisibility: function(visible) {
+ _setSettingsVisibility: function(visible) {
for (let id in this._settingsActions) {
let item = this._settingsActions[id];
item.actor.visible = visible;
this.actor.destroy();
this.emit('destroy');
+
+ Main.sessionMode.disconnect(this._sessionUpdatedId);
+ this._sessionUpdatedId = 0;
}
});
Signals.addSignalMethods(PopupMenuBase.prototype);
},
addMenu: function(menu, position) {
+ if (this._findMenu(menu) > -1)
+ return;
+
let menudata = {
menu: menu,
openStateChangeId: menu.connect('open-state-changed', Lang.bind(this, this._onMenuOpenState)),
},
unlock: function() {
+ if (!this._isLocked)
+ return;
+
if (this._hasLockScreen)
this._clearLockScreen();
this.actor.hide();
this.emit('lock-status-changed', false);
+ Main.sessionMode.popMode('lock-screen');
},
lock: function(animate) {
+ if (this._isLocked)
+ return;
+
if (!this._hasLockScreen)
this._prepareLockScreen();
this._resetLockScreen(animate);
this.emit('lock-status-changed', true);
+ Main.sessionMode.pushMode('lock-screen');
},
});
Signals.addSignalMethods(ScreenShield.prototype);
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Lang = imports.lang;
+const Signals = imports.signals;
const Main = imports.ui.main;
const Params = imports.misc.params;
allowKeybindingsWhenModal: true,
hasRunDialog: false,
hasWorkspaces: false,
+ hasWindows: false,
createSession: Main.createGDMSession,
createUnlockDialog: Main.createGDMLoginDialog,
panel: {
left: [],
center: ['dateMenu'],
right: ['a11y', 'display', 'keyboard',
- 'volume', 'battery', 'lockScreen', 'powerMenu']
+ 'volume', 'battery', 'powerMenu']
}
},
+ 'lock-screen': {
+ hasOverview: false,
+ showCalendarEvents: false,
+ allowSettings: false,
+ allowExtensions: false,
+ allowKeybindingsWhenModal: false,
+ hasRunDialog: false,
+ hasWorkspaces: false,
+ hasWindows: false,
+ panel: {
+ left: ['userMenu'],
+ center: [],
+ right: ['lockScreen']
+ },
+ },
+
'initial-setup': { hasOverview: false,
showCalendarEvents: false,
allowSettings: false,
panel: {
left: [],
center: ['dateMenu'],
- right: ['a11y', 'keyboard', 'volume', 'lockScreen']
+ right: ['a11y', 'keyboard', 'volume']
}
},
allowKeybindingsWhenModal: false,
hasRunDialog: true,
hasWorkspaces: true,
+ hasWindows: true,
createSession: Main.createUserSession,
createUnlockDialog: Main.createSessionUnlockDialog,
panel: {
left: ['activities', 'appMenu'],
center: ['dateMenu'],
right: ['a11y', 'keyboard', 'volume', 'bluetooth',
- 'network', 'battery', 'lockScreen', 'userMenu']
+ 'network', 'battery', 'userMenu']
}
}
};
Name: 'SessionMode',
_init: function() {
- let params = _modes[global.session_mode];
+ global.connect('notify::session-mode', Lang.bind(this, this._sync));
+ this._modeStack = [global.session_mode];
+ this._sync();
+ },
+
+ pushMode: function(mode) {
+ this._modeStack.push(mode);
+ this._sync();
+ },
+
+ popMode: function(mode) {
+ if (this.currentMode != mode || this._modeStack.length === 1)
+ throw new Error("Invalid SessionMode.popMode");
+ this._modeStack.pop();
+ this._sync();
+ },
+
+ get currentMode() {
+ return this._modeStack[this._modeStack.length - 1];
+ },
+ _sync: function() {
+ let params = _modes[this.currentMode];
params = Params.parse(params, _modes[DEFAULT_MODE]);
this._createSession = params.createSession;
delete params.createUnlockDialog;
Lang.copyProperties(params, this);
+ this.emit('updated');
},
createSession: function() {
return null;
},
});
+Signals.addSignalMethods(SessionMode.prototype);
this.menu.addSettingsAction(_("Universal Access Settings"), 'gnome-universal-access-panel.desktop');
},
- setLockedState: function(locked) {
- this.actor.visible = !locked;
- },
-
_buildItemExtended: function(string, initial_value, writable, on_set) {
let widget = new PopupMenu.PopupSwitchMenuItem(string, initial_value);
if (!writable)
this._applet.connect('cancel-request', Lang.bind(this, this._cancelRequest));
},
- setLockedState: function(locked) {
- this._isLocked = locked;
- this._updateKillswitch();
- },
-
_updateKillswitch: function() {
let current_state = this._applet.killswitch_state;
let on = current_state == GnomeBluetooth.KillswitchState.UNBLOCKED;
/* TRANSLATORS: this means that bluetooth was disabled by hardware rfkill */
this._killswitch.setStatus(_("hardware disabled"));
- this.actor.visible = !this._isLocked && has_adapter;
+ this.actor.visible = has_adapter;
if (on) {
this._discoverable.actor.show();
this._inputSourcesChanged();
+ this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+ this._showLayoutItem = this.menu.addAction(_("Show Keyboard Layout"), Lang.bind(this, this._showLayout));
+
+ Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
+ this._sessionUpdated();
+
+ this.menu.addSettingsAction(_("Region and Language Settings"), 'gnome-region-panel.desktop');
+ },
+
+ _sessionUpdated: function() {
// re-using "allowSettings" for the keyboard layout is a bit shady,
// but at least for now it is used as "allow popping up windows
// from shell menus"; we can always add a separate sessionMode
// option if need arises.
- if (Main.sessionMode.allowSettings) {
- this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
- this._showLayoutItem = this.menu.addAction(_("Show Keyboard Layout"), Lang.bind(this, this._showLayout));
- }
- this.menu.addSettingsAction(_("Region and Language Settings"), 'gnome-region-panel.desktop');
- },
-
- setLockedState: function(locked) {
- if (Main.sessionMode.allowSettings) {
- this._showLayoutItem.actor.visible = !locked;
- }
- this.menu.setSettingsVisibility(!locked);
+ this._showLayoutItem.visible = Main.sessionMode.allowSettings;
},
_currentInputSourceChanged: function() {
_init: function() {
this.parent(null, _("Volume, network, battery"));
- this.actor.hide();
this._volume = Main.panel.statusArea.volume;
if (this._volume) {
this._battery.mainIcon.bind_property('visible', this._batteryIcon, 'visible',
GObject.BindingFlags.SYNC_CREATE);
}
- },
-
- setLockedState: function(locked) {
- this.actor.visible = locked;
}
});
this.secondaryIcon = this.addIcon(new Gio.ThemedIcon({ name: 'network-vpn-symbolic' }));
this.secondaryIcon.hide();
- this._isLocked = false;
this._client = NMClient.Client.new();
this._statusSection = new PopupMenu.PopupMenuSection();
}));
},
- setLockedState: function(locked) {
- this._isLocked = locked;
- this._syncNMState();
- },
-
_ensureSource: function() {
if (!this._source) {
this._source = new MessageTray.Source(_("Network Manager"),
_syncNMState: function() {
this.mainIcon.visible = this._client.manager_running;
- this.actor.visible = this.mainIcon.visible && !this._isLocked;
+ this.actor.visible = this.mainIcon.visible;
if (!this._client.networking_enabled) {
this.setIcon('network-offline-symbolic');
this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH);
- this._isLocked = false;
this._deviceItems = [ ];
this._hasPrimary = false;
this._primaryDeviceId = null;
this._devicesChanged();
},
- setLockedState: function(locked) {
- this._isLocked = locked;
- this._syncIcon();
- },
-
_readPrimaryDevice: function() {
this._proxy.GetPrimaryDeviceRemote(Lang.bind(this, function(result, error) {
if (error) {
hasIcon = true;
}
this.mainIcon.visible = hasIcon;
- this.actor.visible = hasIcon && !this._isLocked;
+ this.actor.visible = hasIcon;
},
_devicesChanged: function() {
_init: function() {
this.parent('audio-volume-muted-symbolic', _("Volume"));
- this._isLocked = false;
-
this._control = getMixerControl();
this._volumeMenu = new VolumeMenu(this._control);
this._volumeMenu.connect('icon-changed', Lang.bind(this, function(menu, icon) {
this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
},
- setLockedState: function(locked) {
- this._isLocked = locked;
- this._syncVisibility();
- },
-
_syncVisibility: function() {
- this.actor.visible = this._hasPulseAudio && !this._isLocked;
+ this.actor.visible = this._hasPulseAudio;
this.mainIcon.visible = this._hasPulseAudio;
},
reactive: params.reactive });
},
+ setSensitive: function(sensitive) {
+ this.actor.can_focus = sensitive;
+ this.actor.reactive = sensitive;
+ },
+
update: function() {
let iconFile = this._user.get_icon_file();
if (!GLib.file_test(iconFile, GLib.FileTest.EXISTS))
if (this.actor.mapped)
this._updateUser();
}));
+
+ this.connect('sensitive-changed', function(sensitive) {
+ this._avatar.setSensitive(sensitive);
+ });
},
_restorePresence: function() {
Lang.bind(this, this._updateHaveShutdown));
this._upClient.connect('notify::can-suspend', Lang.bind(this, this._updateSuspendOrPowerOff));
+
+ Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
+ this._sessionUpdated();
},
- setLockedState: function(locked) {
- this.actor.visible = !locked;
+ _sessionUpdated: function() {
+ let allowSettings = Main.sessionMode.allowSettings;
+ this._statusChooser.setSensitive(allowSettings);
+ this._systemSettings.visible = allowSettings;
},
_onDestroy: function() {
let item;
item = new IMStatusChooserItem();
- if (Main.sessionMode.allowSettings)
- item.connect('activate', Lang.bind(this, this._onMyAccountActivate));
+ item.connect('activate', Lang.bind(this, this._onMyAccountActivate));
this.menu.addMenuItem(item);
this._statusChooser = item;
item = new PopupMenu.PopupSeparatorMenuItem();
this.menu.addMenuItem(item);
- if (Main.sessionMode.allowSettings) {
- item = new PopupMenu.PopupMenuItem(_("System Settings"));
- item.connect('activate', Lang.bind(this, this._onPreferencesActivate));
- this.menu.addMenuItem(item);
- }
+ item = new PopupMenu.PopupMenuItem(_("System Settings"));
+ item.connect('activate', Lang.bind(this, this._onPreferencesActivate));
+ this.menu.addMenuItem(item);
+ this._systemSettings = item;
item = new PopupMenu.PopupSeparatorMenuItem();
this.menu.addMenuItem(item);